﻿@using Microsoft.Extensions.Options
@using reCAPTCHA.AspNetCore
@inject IOptions<RecaptchaSettings> options
@model Google.reCAPTCHA.V3.Example.AccountViewModel

@{
    ViewData["Title"] = "Login";
}


<style type="text/css">
    /*这样就可以隐藏reCAPTCHA logo了*/
.grecaptcha-badge {
    /*visibility: hidden !important;*/
}

</style>

<div class="row">
    <div class="text-center col-md-5">
        @if (ViewContext.ModelState.IsValid == false)
        {
            <div class="alert alert-danger">
                <strong>Error</strong>
                <div asp-validation-summary="All" class="danger"></div>
            </div>
        }
            <form class="form-horizontal" asp-action="login" method="post">
                <input type="hidden" id="googleToken" name="googleToken" />
                <div class="form-group">
                    <label class="col-md-3 control-label" >用户名</label>
                    <input type="text" class="form-control" name="username" placeholder="输入用户名:">
                </div>
                <div class="form-group">
                    <label>密码</label>
                    <input type="password" class="form-control" name="password" placeholder="输入密码:">
                </div>
                <button type="submit" class="btn btn-primary">提交</button>
            </form>
    </div>
</div>

@section Scripts
    {
    <script src="https://www.recaptcha.net/recaptcha/api.js?render=@options.Value.SiteKey"></script>
    <script>
        grecaptcha.ready(function () {
            grecaptcha.execute('@options.Value.SiteKey', { action: 'login' }).then(function (token) {
                $("#googleToken").val(token);
            });
        });
    </script>
}

